import request from '../utils/request'
/**
 * 订单相关接口
 */
export default {
  login (mobile, password) {
    const data = {
      uname: mobile,
      pwd: password
    }
    return request({
      url: '/auth/login',
      method: 'post',
      data
    })
  },
  getOrderDetail (id) {
    return request({
      url: '/order/getOrderDetailById.do_',
      method: 'post',
      data: {id: id}
    })
  },
  logout () {
    return request({
      url: '/auth/logout',
      method: 'post'
    })
  },

  getUser (token) {
    return request({
      url: '/auth/info',
      method: 'get',
      params: {token}
    })
  },

  getCartGoods () {
    return request({
      url: '/order/getCartList.do_',
      method: 'get'
    })
  },

  updateCartGoods (num, propertyId) {
    const data = {
      num: num,
      propertyId: propertyId
    }
    return request({
      url: '/order/updataCartgoods.do_',
      method: 'post',
      data
    })
  },

  deleteCartGds (cid) {
    const data = {
      cartId: cid
    }
    return request({
      url: '/order/deleteCartgoods.do_',
      method: 'post',
      data
    })
  },

  // 拉取购物车信息到提交订单页
  getOrderList (goodsList) {
    return request({
      url: '/order/getOrderList.do_',
      method: 'get',
      params: {goodsList}
    })
  },

  // 确认订单页商品信息
  getOrderGoodsList (goodsList, orderId) {
    const data = {
      goodsList: goodsList,
      orderId: orderId
    }
    return request({
      url: '/order/getOrderGoodsList.do_',
      method: 'post',
      data
    })
  },

  // 提交订单状态信息
  confirmOrderInfo (orderInfoList) {
    const data = {
      orderInfoList: orderInfoList
    }
    return request({
      url: '/order/confirmOrderInfo.do_',
      method: 'post',
      data
    })
  },

  // 在确认支付页面，查询用户余额是否充足
  queryBalances (orderPayInfo) {
    const data = {
      orderPayInfo: orderPayInfo
    }
    return request({
      url: '/order/queryBalances.do_',
      method: 'post',
      data
    })
  },

  // 获取用户订单信息列表
  getOrderInfoList (currentPage, pageSize, orderStatus) {
    const data = {
      pageIndex: currentPage,
      pageSize: pageSize,
      status: orderStatus
    }
    return request({
      url: '/order/getOrderInfoList.do_',
      method: 'post',
      data
    })
  },

  // 取消订单
  cancelOrder (orderNum, orderStatus, orderId) {
    const data = {
      orderNum: orderNum,
      status: orderStatus,
      orderId: orderId
    }
    return request({
      url: '/order/cancelOrder.do_',
      method: 'post',
      data
    })
  },

  // 确认收货
  confirmGoods (orderNum, orderStatus, orderId) {
    const data = {
      orderNum: orderNum,
      status: orderStatus,
      orderId: orderId
    }
    return request({
      url: '/order/confirmGoods.do_',
      method: 'post',
      data
    })
  },

  // 删除订单
  goDelete (OrderId) {
    const data = {
      OrderId: OrderId
    }
    return request({
      url: '/order/goDelete.do_',
      method: 'post',
      data
    })
  },
  checkStock (goodsList) {
    return request({
      url: '/order/checkStock.do_',
      method: 'post',
      params: {goodsList: goodsList.join(`,`)}
    })
  },
  // 获取会员折扣点
  getMemberDiscountPoint () {
    return request({
      url: 'gds/goods/getMemberDiscountPoint.do_',
      method: 'get'
    })
  },
  // 获取评价状态商品详情
  getCommentGoodsDetail (query) {
    return request({
      url: '/order/getCommentGoodsDetail.do_',
      method: 'get',
      params: query
    })
  }
}
